<template>
    <div class="warp">
        <NavBar title="选择地址" :leftArrow="true" :clickLeft="() => $router.go(-1)" />
        <Map :baseAddress="{ lnglat, address }" @setAddress="setAddress" />
    </div>
</template>

<script>
import NavBar from '../../../components/NavBar'
import Map from '@/components/Map'
import { mapActions } from 'vuex'
// import Vue from 'vue'
// import VueAMap from 'vue-amap'
export default {
    components: {
        NavBar,
        Map
    },
    data(){
        return {
            lnglat: '',
            address: ''
        }
    },
    methods: {
        ...mapActions('order', ['setAdd']),
        back(){
            this.$router.go(-1)
        },
        setAddress(val){
            console.log('setAddress', val)
            let { addForm } = this.$store.getters
                addForm.address = val[val.length - 1].address
                addForm.geom = val.map(item => item.lnglat)
                addForm.area = val.length
            this.setAdd(addForm)
            this.$router.go(-1)
            //?address=${JSON.stringify(val)}
            // this.$router.replace(`/create/${this.$route.query.id}`)
        }
    },
    created(){
        let { lnglat, address } = this.$route.query
        this.lnglat = lnglat
        this.address = address
    }
}
</script>

<style lang="scss" scoped>
    .warp{
        height: 100%;
        position: relative;
    }
</style>